import 'package:flutter/material.dart';
import 'package:mybase/base_new/help/JJShock.dart';
import 'package:mybase/base_new/mixin/JJClick.dart';
import 'package:mybase/base_new/mixin/JJModify.dart';

class JJLine extends StatelessWidget with JJModify, JJClick {
  /// 方向,默认竖直方向
  Axis direction;

  /// 数组
  List<Widget>? children;

  /// 主轴
  MainAxisAlignment mainAxisAlignment;

  /// 次轴
  CrossAxisAlignment crossAxisAlignment;

  JJLine({
    super.key,

    /// 当前组件属性
    required this.children,
    this.direction = Axis.vertical,
    this.mainAxisAlignment = MainAxisAlignment.start,
    this.crossAxisAlignment = CrossAxisAlignment.start,

    // JJModify属性
    AlignmentGeometry? alignment,
    EdgeInsetsGeometry? padding,
    Color? color,
    Decoration? decoration,
    Decoration? foregroundDecoration,
    double? width,
    double? height,
    BoxConstraints? constraints,
    EdgeInsetsGeometry? margin,
    Matrix4? transform,
    AlignmentGeometry? transformAlignment,
    Clip clipBehavior = Clip.none,
    bool unconstrainedBox = false,

    // JJClick属性
    Function? onClick,
    Function()? onLongClick,
    bool? hiddenKeepFrame,
    bool? hiddenClearFrame,
    int? minClickIntervalMill,
    double? clickedAlpha,
    double? clickedScale,
    int? scaleMill,
    ShockType? shockType,
    bool? ignoreInteraction,
    bool? ignoreInteractionAll,
    String? clickName,
    ClickType? clickType,
  }) {
    // JJModify
    this.alignment = alignment;
    this.padding = padding;
    this.color = color;
    this.decoration = decoration;
    this.foregroundDecoration = foregroundDecoration;
    this.width = width;
    this.height = height;
    this.constraints = constraints;
    this.margin = margin;
    this.transform = transform;
    this.clipBehavior = clipBehavior;
    this.transformAlignment = transformAlignment;
    this.unconstrainedBox = unconstrainedBox;

    // JJClick
    this.onClick = onClick;
    this.onLongClick = onLongClick;
    this.hiddenKeepFrame = hiddenKeepFrame;
    this.hiddenClearFrame = hiddenClearFrame;
    this.minClickIntervalMill = minClickIntervalMill;
    this.clickedAlpha = clickedAlpha;
    this.clickedScale = clickedScale;
    this.scaleMill = scaleMill;
    this.shockType = shockType;
    this.ignoreInteraction = ignoreInteraction;
    this.ignoreInteractionAll = ignoreInteractionAll;
    this.clickName = clickName;
    this.clickType = clickType;
  }

  // 固定搭配
  @override
  Widget build(BuildContext context) {
    return clickBuild(context, modifyBuild(context));
  }

  @override
  Widget selfBuild(BuildContext context) {
    return Flex(
      direction: direction,
      mainAxisAlignment: mainAxisAlignment,
      crossAxisAlignment: crossAxisAlignment,
      children: children ?? [],
    );
  }
}
